/* Controllers */
app.controller('homeCtrl',['$scope','$location', '$timeout', function ($scope,$location,$timeout) {
    var myChart = echarts.init(document.getElementById('main'));
    // 指定图表的配置项和数据
    var option = {
        geo: {
            map: '广东',
            roam: 'move',
            aspectScale: 0.8,
            zoom:2.2,
            top:'20%',
            label: {
                normal : {
                    show:false,
                    textStyle : {
                        color : '#0ea3f1',
                        fontSize : 8
                    }
                },
                emphasis: {
                    show: false,
                    textStyle : {
                        color : '#0ea3f1',
                        fontSize : 8
                    }
                }
            },
            itemStyle: {
                normal: {
                    areaColor: '#fff',
                    borderColor: '#aac1d4'
                },
                emphasis: {
                    areaColor: '#ffc100'
                }
            }
        },
        series : [
            {
                name: 'pm2.5',
                type: 'effectScatter',
                coordinateSystem: 'geo',
                data: $config.geoCoordMap,
                symbolSize: 12,
                symbol :'image://'+__uri('/src/img/icon-address.png'),
                showEffectOn: 'render',
                rippleEffect: {
                    brushType: 'fill'
                },
                hoverAnimation: true,
                label: {
                    normal: {
                        formatter: '{b}',
                        position: 'bottom',
                        show: true,
                        textStyle : {
                            color : '#0ea3f1',
                            fontSize : 14
                        }
                    }
                },
                itemStyle: {
                    normal: {
                        color: '#0ea3f1',
                        shadowBlur: 10,
                        shadowColor: '#0ea3f1'
                    }
                },
                zlevel: 1
            }
        ]
    };
    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);

    myChart.on('click', function (params) {
        // $scope.showAlert(params.name);
        $scope.$apply(function(){
            $timeout(function(){
                $scope.showAlert(params.name);
            },10);
        });
        // console.log(params)
    });
    $scope.isIndex = true;
    $scope.toHome = function(){
        $scope.isIndex = false;
    }
}]);